hsla: Just store floats
authorMatthias Clasen <mclasen@redhat.com>
Sat, 25 Jul 2020 04:29:42 +0000 (00:29 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Sat, 25 Jul 2020 15:56:05 +0000 (11:56 -0400)
We are using floats for rgb, and we don't need more precision
for hsl colors either. We use hsl for computing color expressions
like shade(), lighter() and darker(), which are not precisely
specified anyway.

This commit updates the one test where the output changes a
tiny bit due to this.

gtk/gtkhsla.c
gtk/gtkhslaprivate.h
testsuite/css/parser/color.ref.css

index abb4aaf68919e1a294c95fa4b75807b7fd9d8c7f..9692e3e59fd1c92015e358205138880c4e0b30c8 100644 (file)
 
 void
 _gtk_hsla_init (GtkHSLA *hsla,
-                double   hue,
-                double   saturation,
-                double   lightness,
-                double   alpha)
+                float    hue,
+                float    saturation,
+                float    lightness,
+                float    alpha)
 {
   g_return_if_fail (hsla != NULL);
 
@@ -43,12 +43,12 @@ void
 _gtk_hsla_init_from_rgba (GtkHSLA       *hsla,
                           const GdkRGBA *rgba)
 {
-  double min;
-  double max;
-  double red;
-  double green;
-  double blue;
-  double delta;
+  float min;
+  float max;
+  float red;
+  float green;
+  float blue;
+  float delta;
   
   g_return_if_fail (hsla != NULL);
   g_return_if_fail (rgba != NULL);
@@ -112,10 +112,10 @@ void
 _gdk_rgba_init_from_hsla (GdkRGBA       *rgba,
                           const GtkHSLA *hsla)
 {
-  double hue;
-  double lightness;
-  double saturation;
-  double m1, m2;
+  float hue;
+  float lightness;
+  float saturation;
+  float m1, m2;
   
   lightness = hsla->lightness;
   saturation = hsla->saturation;
@@ -186,7 +186,7 @@ _gdk_rgba_init_from_hsla (GdkRGBA       *rgba,
 void
 _gtk_hsla_shade (GtkHSLA       *dest,
                  const GtkHSLA *src,
-                 double         factor)
+                 float          factor)
 {
   g_return_if_fail (dest != NULL);
   g_return_if_fail (src != NULL);
index 9f038cce25182caf1e4593979455ad50ab577d8b..145daf746128baf9de04e19e40635912059dfba8 100644 (file)
@@ -25,17 +25,17 @@ G_BEGIN_DECLS
 typedef struct _GtkHSLA GtkHSLA;
 
 struct _GtkHSLA {
-  double hue;
-  double saturation;
-  double lightness;
-  double alpha;
+  float hue;
+  float saturation;
+  float lightness;
+  float alpha;
 };
 
 void            _gtk_hsla_init              (GtkHSLA          *hsla,
-                                             double            hue,
-                                             double            saturation,
-                                             double            lightness,
-                                             double            alpha);
+                                             float             hue,
+                                             float             saturation,
+                                             float             lightness,
+                                             float             alpha);
 void            _gtk_hsla_init_from_rgba    (GtkHSLA          *hsla,
                                              const GdkRGBA    *rgba);
 /* Yes, I can name that function like this! */
@@ -44,7 +44,7 @@ void            _gdk_rgba_init_from_hsla    (GdkRGBA          *rgba,
 
 void            _gtk_hsla_shade             (GtkHSLA          *dest,
                                              const GtkHSLA    *src,
-                                             double            factor);
+                                             float             factor);
 
 G_END_DECLS
 
index 2241017d32de1d6c31d8fda9093f61a73515d899..780d21c565540499135de63e0bc650cb0645c2e4 100644 (file)
@@ -49,7 +49,7 @@ l {
 }
 
 m {
-  color: rgb(255,77,77);
+  color: rgb(255,76,76);
 }
 
 n {